package com.coldchain.admin.rpc;

import com.coldchain.admin.template.service.IExpressionService;
import com.coldchain.authclient.annotation.CheckUserToken;
import com.coldchain.common.msg.ObjectRestResponse;
import com.coldchain.message.core.constant.OrderMessageType;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName ExpressionRpcController
 * @Description TODO
 * @Author fangliai
 * @Date 2018/9/22 13:32
 * @Vesion 1
**/
@RestController
@CheckUserToken
public class ExpressionRpcController {
    @Autowired
    private IExpressionService expressionService;
    /**
     * 获取订单阶格
     * @param orderKm
     * @param delivery
     * @param citycode
     * @param carTypeId
     * @param isInter
     * @return
     */
    @ApiOperation(value = "计算订单价格",httpMethod = "POST")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "orderKm",name = "订单总里程",dataType = "integer",required = true),
            @ApiImplicitParam(value = "delivery",name = "配送点数量",dataType = "integer",required = true),
            @ApiImplicitParam(value = "areaId",name = "地区ID",dataType = "integer",required = true),
            @ApiImplicitParam(value = "citycode",name = "车型Id",dataType = "string",required = true),
            @ApiImplicitParam(value = "isInter",name = "是否是城际配送",dataType = "integer",required = true)
    })
    @PostMapping("/expression/getOrderPrice")
    public ObjectRestResponse<OrderMessageType> getOrderPrice(Integer orderKm, Integer delivery,
                                                              String citycode, Long carTypeId, Boolean isInter){
        return new ObjectRestResponse<>().data(
                expressionService.getOrderPriceByCarTypeAndArea(
                        orderKm,
                        delivery,
                        citycode,
                        carTypeId,
                        isInter
                ));
    }
}
